macro_rules! define_error {
    ($msg_name:ident,$code_value:expr,$msg_value:expr) => {
        pub const $msg_name: $crate::errors::error_trait::ConstContentError =
            $crate::errors::error_trait::ConstContentError::new($msg_value, $code_value, None);
    };
    ($msg_name:ident,$code_value:expr,$msg_value:expr,$status_code:ident) => {
        pub const $msg_name: $crate::errors::error_trait::ConstContentError =
            $crate::errors::error_trait::ConstContentError::new(
                $msg_value,
                $code_value,
                Some(actix_http::StatusCode::$status_code),
            );
    };
}

define_error!(MSG_UNKNOWN, 1000, "未知错误", INTERNAL_SERVER_ERROR);
define_error!(
    MSG_WECHAT_NOT_CONFIG,
    1001,
    "微信相关配置未设置",
    BAD_REQUEST
);
define_error!(
    MSG_GITHUB_NOT_CONFIG,
    1002,
    "Github相关配置未设置",
    BAD_REQUEST
);
define_error!(MSG_SERVICE_OFFLINE, 1003, "服务离线", INTERNAL_SERVER_ERROR);

// ----------------- mdb 2000 - 2999 ----------------------------
define_error!(MSG_MDB, 2000, "数据错误，请稍后重试", INTERNAL_SERVER_ERROR);
define_error!(
    MSG_MDB_NOT_FOUND,
    2001,
    "未找到相关数据，请稍后重试",
    NOT_FOUND
);
define_error!(
    MSG_MDB_MAYBE_BROKEN,
    2002,
    "数据库可能已损坏，请联系管理员检查",
    INTERNAL_SERVER_ERROR
);

// ----------------- user 3000 - 3999 ---------------------------
define_error!(
    MSG_USER_BREAK,
    3000,
    "用户信息不完整",
    INTERNAL_SERVER_ERROR
);
define_error!(MSG_USER_ID_IS_NOT_EXIST, 3001, "用户ID不存在", NOT_FOUND);
define_error!(MSG_REQUIRE_AUTHORIZE, 3002, "用户权限不足", UNAUTHORIZED);
define_error!(MSG_USER_ALREADY_EXIST, 3003, "用户已存在", CONFLICT);
define_error!(
    MSG_NOT_ALLOW_GIVE_MULTI_TYPE_AUTH,
    3004,
    "不允许同时赋予多个类型的权限",
    BAD_REQUEST
);
define_error!(
    MSG_USER_ACCOUNT_NOT_VALID,
    3005,
    "账号或者密码不正确",
    BAD_REQUEST
);
define_error!(
    MSG_NOT_FOUND_USER_IN_SESSION,
    3006,
    "无法在会话中查找到用户信息",
    BAD_REQUEST
);
define_error!(MSG_INVALID_CODE, 3007, "注册验证码不正确", BAD_REQUEST);

// ----------------- form 4000 - 4999 ----------------------------
define_error!(
    MSG_FORM_JOIN_MAST_HAVE_ONE,
    4000,
    "纳新表单必须存在一个",
    BAD_REQUEST
);
define_error!(
    MSG_FORM_ID_IS_NOT_EXIST,
    4001,
    "表单ID不存在",
    INTERNAL_SERVER_ERROR
);
define_error!(
    MSG_FORM_LAYOUT_IS_EMPTY,
    4002,
    "表单布局属性为空",
    BAD_REQUEST
);
define_error!(
    MSG_APPLICATION_STATUS_IS_EMPTY,
    4003,
    "表单申请的状态为空,此表单可能已归档",
    BAD_REQUEST
);
define_error!(
    MSG_APPLICATION_STATUS_NOT_FOUND,
    4004,
    "未查找指定的表单申请状态",
    NOT_FOUND
);
define_error!(
    MSG_FORM_NOT_CONTAIN_START_STATUS,
    4005,
    "未找到表单的开始状态，请与社团或者我们联系",
    INTERNAL_SERVER_ERROR
);
define_error!(
    MSG_FORM_NOT_ALLOW_MULTI_APPLY,
    4006,
    "不允许同时申请多个表单",
    BAD_REQUEST
);
// ----------------- path_ids 5000 - 5999 ----------------------------

define_error!(MSG_REQUIRE_USER_ID_IN_PATH, 5000, "需要在路径中提供user_id");
define_error!(MSG_REQUIRE_CLUB_ID_IN_PATH, 5001, "需要在路径中提供club_id");
define_error!(MSG_REQUIRE_FORM_ID_IN_PATH, 5002, "需要在路径中提供form_id");
define_error!(
    MSG_REQUIRE_ASSETS_ID_IN_PATH,
    5003,
    "需要在路径中提供assets_id"
);
define_error!(
    MSG_REQUIRE_APPLICATION_ID_IN_PATH,
    5004,
    "需要在路径中提供application_id"
);
define_error!(
    MSG_REQUIRE_INVITE_ID_IN_PATH,
    5005,
    "需要在路径中提供invite_id"
);
define_error!(
    MSG_REQUIRE_MESSAGE_ID_IN_PATH,
    5006,
    "需要在路径中提供message_id"
);

// ---------------- invite 7000-7999 --------------------
define_error!(
    MSG_USER_SHOULD_IN_INVITE_TOKEN,
    7000,
    "用户还未接受过此社团的邀请，请先发送邀请链接给用户确认再将用户邀请到社团",
    BAD_REQUEST
);
define_error!(
    MSG_INVITE_TOKEN_ALREADY_USED,
    7001,
    "用户已经接受过邀请",
    GONE
);

// -------------- other 8000 - 8999 ----------------------

define_error!(MSG_ID_IS_NOT_EXIST, 8000, "ID不存在", NOT_FOUND);
define_error!(MSG_IN_BLACK_LIST, 8001, "正处于黑名单中");
define_error!(
    MSG_REQUIRE_FORM_DATA,
    8002,
    "需要同时提交表单值",
    BAD_REQUEST
);
define_error!(MSG_ALREADY_JOIN_ACTIVITY, 8003, "已经加入过活动", CONFLICT);
define_error!(MSG_ALREADY_WATCH, 8004, "已经记录过观看信息", CONFLICT);

define_error!(MSG_NOT_ALLOW_REGISTER, 8005, "不允许注册", BAD_REQUEST);

define_error!(MSG_EMAIL_CONFIG_NOT_SET, 8006, "邮箱未配置", BAD_REQUEST);
define_error!(
    MSG_EMAIL_VALID_NOT_ENABLE,
    8007,
    "邮箱验证未开启",
    BAD_REQUEST
);
define_error!(
    MSG_EMAIL_VALID_TOO_MORE,
    8008,
    "邮箱验证次数过多，请稍后再试",
    BAD_REQUEST
);
define_error!(MSG_EMAIL_INVALID, 8009, "邮箱格式非法", BAD_REQUEST);
// -------------- not found 9000 -9999 -------------------

define_error!(MSG_SECTION_IS_NOT_FOUND, 9000, "目标板块不存在", NOT_FOUND);
define_error!(MSG_ARTICLE_IS_NOT_FOUND, 9001, "目标文章不存在", NOT_FOUND);
define_error!(
    MSG_CLUB_ACTIVITY_IS_NOT_FOUND,
    9002,
    "目标社团活动不存在",
    NOT_FOUND
);
define_error!(
    MSG_BLACKLIST_IS_NOT_FOUND,
    9003,
    "目标黑名单不存在",
    NOT_FOUND
);
define_error!(MSG_MESSAGE_IS_NOT_FOUND, 9004, "目标消息不存在", NOT_FOUND);
